package com.ocom.ugcapi.controller;

import com.ocom.common.constant.WxServiceUrl;
import com.ocom.common.resp.Result;
import com.ocom.common.vo.payconfig.FeeDataListVo;
import com.ocom.common.vo.payconfig.FeeItemListVo;
import com.ocom.common.vo.ugcapi.GzhUserInfo;
import com.ocom.ugcapi.client.PayConfigClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@Slf4j
@RestController
public class FeeDataController {

    @Resource
    private PayConfigClientService payConfigClientService;
    @PostMapping(WxServiceUrl.Url_getPersonFeeList)
    public Result getPersonFeeList(@RequestBody Map<String,Object> map){
        GzhUserInfo user = (GzhUserInfo) map.get("userInfo");
        FeeDataListVo request = new FeeDataListVo();
        request.setComId(user.getComId());
        request.setPId(user.getPId().intValue());
        request.setDataStatus(Integer.parseInt(map.get("dataStatus").toString()));
        return payConfigClientService.feeDataByPerson(request);
    }

    @PostMapping(WxServiceUrl.Url_getFeePayWay)
    public Result getFeePayWay(@RequestBody Map<String,Object> map){
        GzhUserInfo user = (GzhUserInfo) map.get("userInfo");
//        System.out.println("getComId===="+user.getComId());
        FeeItemListVo request = new FeeItemListVo();
        request.setComId(user.getComId());
        request.setFeeItemId(Integer.parseInt(map.get("feeItemId").toString()));
        Result result = payConfigClientService.feeItemListByWay(request);
        if(result.getCode()!=200){
            return result;
        }
        Object strData = result.getData();
        Long lAccountId = Long.valueOf(String.valueOf(strData));
        Result resultWay = payConfigClientService.getRechargePayWay(user.getComId(),lAccountId,1);
        return resultWay;
    }
}
